#pragma once

#include <ctime>
#include <initializer_list>
#include <iterator>
#include <memory>
#include <sstream>
#include <string>
#include <vector>

#include "rpc_defines.h"

namespace kratos {
namespace service {
class ServiceContext;
}
} // namespace kratos

namespace rpc {

class Rpc;
class StubCall;
class Transport;

// RPC service interface
class RpcService {
  kratos::service::ServiceContext *ctx_{nullptr};
  rpc::ServiceUUID service_uuid_{rpc::INVALID_SERVICE_UUID};

public:
  // dtor
  virtual ~RpcService() {}
  // Invoked by framework after spawned
  virtual bool onAfterFork(rpc::Rpc *rpc) { return true; }
  // Invoked by framework before uninitialization
  virtual bool onBeforeDestory(rpc::Rpc *rpc) { return true; }
  // Tick
  virtual void onTick(std::time_t ms) { return; }
  // Call service method
  virtual void onServiceCall(std::shared_ptr<StubCall> callPtr) { return; }
  // Query context
  kratos::service::ServiceContext *getContext() { return ctx_; }
  // Setup context
  void setContext(kratos::service::ServiceContext *ctx) { ctx_ = ctx; }
  rpc::ServiceUUID getServiceUUID() { return service_uuid_; }
  void setServiceUUID(rpc::ServiceUUID uuid) { service_uuid_ = uuid; }
};

} // namespace rpc
